Hosted Static Site
Embed AI Assistant in code source
- Open your Assistant instance and find the embed script tag following these instructions:
- Within the Assitant Builder's sidebar, navigate to the "Integrations" section
- Under the "Essential channels" section select "Open" within the "Webchat" channel
- Select the appropriate environment and navigate to the "Embed" tab
- Copy the provided script
- Create a new HTML file using an editor of your choice and create the general structure of the file as shown below.
<html>
<head></head>
<body>
<title>My Test Page</title>
<p>The body of my page.</p>
<-- Insert Script Element -->
</body>
</html>
- Add your script element as shown below and open the HTML file using a browser to confirm the watsonx assistant chat is rendering correctly. You can also simply copy the code below and add your
integrationID
,serviceInstanceID
, and update yourregion
.
<html>
<head></head>
<body>
<title>My Test Page</title>
<p>The body of my page.</p>
<script>
window.watsonAssistantChatOptions = {
integrationID: "[Insert integrationID]", // The ID of this integration.
region: "us-south", // The region your integration is hosted in.
serviceInstanceID: "[Insert serviceInstanceID]", // The ID of your service instance.
onLoad: async (instance) => { await instance.render(); }
};
setTimeout(function(){
const t=document.createElement('script');
t.src="https://web-chat.global.assistant.watson.appdomain.cloud/versions/" + (window.watsonAssistantChatOptions.clientVersion || 'latest') + "/WatsonAssistantChatEntry.js";
document.head.appendChild(t);
});
</script>
</body>
</html>
info
If you wish to customize the web chat with options such as adding a restart button or adjusting the size, follow these links:
Host Static Site
Create Cloud Object Storage (COS) Instance
- Go to the dedicated IBM Cloud Account "Resource" List here and click "Create Resource +"
- Search and select "Object Storage"
- Select "IBM Cloud" as the infrastructure and the appropriate pricing plan
- Name the service and click "Create"
Create a Custom COS Bucket
- From the "Resource" List select the newly created COS instance
- Click "Create a Custom Bucket"
- Enter a valid bucket name and select the appropriate values for "Resiliency", "Location", "Storage class", "Object Versioning" and "Immutablity"
- Within the section "Advanced configurations (optional)" click the "Add +" for "Static website hosting"
- Ensure the "Public access" toggle is switched to "On"
- Enter the name of the target html file which will be used to build the desired web app
- Click "Save" and then click "Create bucket"
Upload HTML file
- Upload the HTML file you created here